﻿Imports DataAccess
Public Class Util

    Public Shared CurrentParam As PARAMETROS = Business.ParametrosBL.GetParametros
    Public Shared GridFont As Integer = 8
    Public Shared GridFontIngresos As Integer = 11
    Public Enum TipoPago
        Factura = 1
        Boleta = 2
        DesctoPOS = 3
        FacturaVenta = 4
    End Enum
    Public Shared Function ValidaRut(ByRef wRut As String) As Boolean
        Dim Final As Double, Resul As Double, Tot As Double, Dig As String
        Dim r1, r2, r3, r4, r5, r6, r7, r8 As Integer

        r1 = CInt(Val(Mid(wRut, 1, 1)) * 3)
        r2 = CInt(Val(Mid(wRut, 2, 1)) * 2)
        r3 = CInt(Val(Mid(wRut, 4, 1)) * 7)
        r4 = CInt(Val(Mid(wRut, 5, 1)) * 6)
        r5 = CInt(Val(Mid(wRut, 6, 1)) * 5)
        r6 = CInt(Val(Mid(wRut, 8, 1)) * 4)
        r7 = CInt(Val(Mid(wRut, 9, 1)) * 3)
        r8 = CInt(Val(Mid(wRut, 10, 1)) * 2)
        Dig = UCase(Mid(wRut, 12, 1))

        Tot = r1 + r2 + r3 + r4 + r5 + r6 + r7 + r8
        Resul = Tot Mod 11
        Final = 11 - Resul
        If Dig = "0" Then Dig = "11"
        If Dig = "K" Then Dig = "10"
        Dig = Val(Dig).ToString
        If Final = CDbl(Dig) Then
            Return True
        Else
            Return False
        End If
    End Function
    Public Shared Sub Siguiente()
        System.Windows.Forms.SendKeys.Send(("{TAB}"))
    End Sub
    Public Shared Sub MensajeError(ByVal xError As String)
        MsgBox(xError, MsgBoxStyle.Critical, "ERROR")
    End Sub
    Public Shared Sub Mensaje(ByVal xMensaje As String)
        MsgBox(xMensaje, MsgBoxStyle.Information, "MENSAJE")
    End Sub
    Public Shared Function Pregunta(ByVal xPregunta As String) As Boolean
        Dim Respuesta = MsgBox(xPregunta, MsgBoxStyle.YesNo + MsgBoxStyle.Question, "PREGUNTA")
        If Respuesta = vbYes Then
            Pregunta = True
        Else
            Pregunta = False
        End If
    End Function
End Class
